#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n = 0;
    cin >> n;
    vector<string> v(n);
    for (int i = 0; i < n; ++i) 
    {
        cin >> v[i];
    }
    bool flag_lex = true, flag_len = true;
    for (int i = 0; i < n - 1; ++i) 
    {
        if (v[i] > v[i + 1])
            flag_lex = false;
        if (v[i].size() > v[i + 1].size())
            flag_len = false;
    }
    if (flag_lex && flag_len)
        cout << "both";
    else if (flag_lex)
        cout << "lexicographically";
    else if (flag_len)
        cout << "lengths";
    else
        cout << "none";
    return 0;
}